package com.xingongchang.baolebei.activity;

import java.util.ArrayList;
import java.util.List;

import com.xingongchang.baolebei.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class YingDao extends Activity{
	ViewPager mypage;
	List<View> list = null;
	ImageView ivJinru;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.yingdao);
		mypage = (ViewPager) findViewById(R.id.mypage);
		LayoutInflater inflater = LayoutInflater.from(this);
		View view1 = inflater.inflate(R.layout.yindao_01, null);
		View view2 = inflater.inflate(R.layout.yindao_02, null);
		View view3 = inflater.inflate(R.layout.yindao_03, null);
		list = new ArrayList<View>();
		list.add(view1);
		list.add(view2);
		list.add(view3);
		MyPageAdapter adapter = new MyPageAdapter(list);
		mypage.setAdapter(adapter);
		Button button=(Button) view3.findViewById(R.id.bu);
		button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(YingDao.this,
						BaolebeiActivity.class);
				startActivity(intent);
			}
		});
	}

	class MyPageAdapter extends PagerAdapter {
		List<View> list;

		MyPageAdapter(List<View> list) {
			this.list = list;
		}

		@Override
		public int getCount() {
			return list.size();
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			container.removeView(list.get(position));
		}

		@Override
		public Object instantiateItem(ViewGroup container, int position) {
			container.addView(list.get(position));
			return list.get(position);
		}

		@Override
		public boolean isViewFromObject(View arg0, Object arg1) {
			return arg0 == arg1;
		}
	}
} 
